{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1. 异常练习"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "出错了\n"
     ]
    }
   ],
   "source": [
    "try:\n",
    "    a = eval(input(\"请输入第一个数:\"))\n",
    "    b = eval(input(\"请输入第二个数:\"))\n",
    "    c = a/b\n",
    "except:\n",
    "    print(\"出错了\")\n",
    "else:\n",
    "    print(\"两数相除的结果为:\",c)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2 列表练习"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[95, 88, 65, 75, 60, 100, 99, 97, 55, 30]\n",
      "65\n",
      "55\n",
      "95\n",
      "88\n",
      "65\n",
      "100\n",
      "60\n",
      "100\n",
      "99\n",
      "97\n",
      "55\n",
      "30\n",
      "100\n",
      "[30, 55, 60, 65, 88, 95, 97, 99, 100, 100]\n",
      "2\n",
      "[50, 100, 100, 99, 97, 95, 60, 65, 60, 55, 30]\n"
     ]
    }
   ],
   "source": [
    "# 2.1. 定义一个列表存放10个学生成绩\n",
    "maths = [95,88,65,75,60,100,99,97,55,30]\n",
    "print(maths)\n",
    "# 2.2. 打印第3个学生的成绩、打印倒数第2个学生成绩\n",
    "print(maths[2])\n",
    "print(maths[-2])\n",
    "# 2.3. 将第4个学生的成绩改为100分\n",
    "maths[3] = 100\n",
    "# 2.4. 遍历打印所有学生成绩\n",
    "for i in maths:\n",
    "    print(i)\n",
    "# 2.5. 打印最高分和最低分和总分\n",
    "print(max(maths))\n",
    "# 2.6. 打印排序后的学生成绩\n",
    "maths.sort()\n",
    "print(maths)\n",
    "# 2.7. 添加一个50分在最后\n",
    "maths.append(50)\n",
    "# 2.8 插入一个60在位置6\n",
    "maths.insert(5,60)\n",
    "# 2.9 弹出第5个学生成绩\n",
    "maths.pop(4)\n",
    "# 2.10. 查找60分同学排在第几个\n",
    "print(maths.index(60))\n",
    "# 2.11 翻转列表\n",
    "maths.reverse()\n",
    "print(maths)\n",
    "# 2.12 统计60分同学有几个\n",
    "print(maths.count(60))\n",
    "# 2.13 复制一份列表\n",
    "maths2 = maths.copy()\n",
    "# 2.14 清空所有成绩\n",
    "maths.clear()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
